<template>
    <h3>登入</h3>
        <table border="1">
            <tbody>
                 <tr>
                    <th>账号</th>
                    <th>
                        <input type="text" v-model="data.LoginName">
                    </th>
                 </tr>   
                 <tr>
                    <th>密码</th>
                    <th>
                        <input type="text" v-model="data.LoginPwd">
                    </th>
                 </tr>   
                 <tr>
                    <th colspan="2">
                        <input type="button" value="登入" @click="Deng" >
                    </th>
                    <th></th>
                 </tr>   
            </tbody>
        </table>
</template>

<script setup lang="ts">

import axios from 'axios';
import { ref } from 'vue';

const data=ref({
        "LoginId": 0,
        "LoginName": "",
        "LoginPwd": "",
})

const Deng=()=>{
    if(data.value.LoginName==""){
        alert('账号不能为空')
         return;
    }
    if(data.value.LoginPwd==""){
        alert('密码不能为空')
        return;
    }

    axios.get("https://localhost:7069/api/Member/Login",{params:data.value}).then(res=>{
        if(res.data.LoginId>0){
            alert('登入成功')
                return;
        }
        if(res.data.LoginId==-1){
            alert('帐号不存在')
            return;
        }
        if(res.data.LoginId==-2){
            alert('密码不正确')
            return;
        }
    })


}


</script>




